/**
 * admui-basic v2.1.0 (http://www.admui.com/)
 * Copyright 2015-2019 Admui Team
 * Licensed under the Admui License 1.1 (http://www.admui.com/about/license)
 */
(function(document, window, $) {
  'use strict';

  var dynamicChart;
  var dynamicRedChart;
  var dynamicGreenChart;
  var dynamicOrangeChart;

  // 公用定时函数
  var timeOut = function(objs) {
    var random = Math.round(Math.random() * 10);
    var values = objs.text().split(',');
    values.shift();
    values.push(random);

    objs.text(values.join(',')).change();
  };

  $(function() {
    // 默认 - 动态图示例
    dynamicChart = $('#examplePeityDynamic').peity('line', {
      width: 64,
      fill: [$.getColor('purple', 200)],
      stroke: $.getColor('purple', 500),
      height: 22
    });

    // 红色 - 动态图示例
    dynamicRedChart = $('#examplePeityDynamicRed').peity('line', {
      width: 64,
      fill: [$.getColor('red', 200)],
      stroke: $.getColor('red', 500),
      height: 22
    });

    // 绿色 - 动态图示例
    dynamicGreenChart = $('#examplePeityDynamicGreen').peity('line', {
      width: 64,
      fill: [$.getColor('green', 200)],
      stroke: $.getColor('green', 500),
      height: 22
    });

    // 桔色 - 动态图示例
    dynamicOrangeChart = $('#examplePeityDynamicOrange').peity('line', {
      width: 64,
      fill: [$.getColor('orange', 200)],
      stroke: $.getColor('orange', 500),
      height: 22
    });

    setInterval(function() {
      timeOut(dynamicChart);
      timeOut(dynamicRedChart);
      timeOut(dynamicGreenChart);
      timeOut(dynamicOrangeChart);
    }, 1000);
  });
})(document, window, jQuery);
